#include <stdio.h>

int RomaNum(char num)
{
    if(num == 'I')
    return 1;
    else if(num == 'V')
    return 5;
    else if(num == 'X')
    return 10;
    else if(num == 'L')
    return 50;
    else if(num == 'C')
    return 100;
    else if(num == 'D')
    return 500;
    else if(num == 'M')
    return 1000;
}

int main()
{
    int sum = 0;
    char num[101] = {0};//罗马数字符号共七个，每个重复不超过三次
    scanf("%s", num);
    for(int i = 0; i < 100&&num[i] != '\0'; i++)
    {
        int s1 = RomaNum(num[i]);
        int s2 = RomaNum(num[i + 1]);
        if(s1 < s2&&s1 == 1||s1 == 10||s1 == 100)
        {
            sum += s2 - s1;
            i++;
        }
        else
        {
            sum += s1;
        }
    }
    printf("%d\n", sum);

    return 0;
}